package com.android.component;

import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;

import com.utils.HTRinger;


public class MeidaPlayTest extends CommonTest {
    HTRinger ringer;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        ringer = new HTRinger(this);
        setButton("播放", onClickListener);
        setButton("停止", onClickListener);

        setButton("外放", onClickListener);
        setButton("耳机", onClickListener);

        setButton("call binder function", onClickListener);

    }


    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();
        if (id == R.id.action_settings) {
            return true;
        }
        return super.onOptionsItemSelected(item);
    }

    View.OnClickListener onClickListener = new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            if (v == btns[0]) {
                ringer.play(MeidaPlayTest.this);
            } else if (v == btns[1]) {
                ringer.stop();
            } else if (v == btns[2]) {
                ringer.openSpeaker(MeidaPlayTest.this);
            } else if (v == btns[3]) {
                ringer.closeSpeaker(MeidaPlayTest.this);
            }
        }
    };
}
